#main.py
#Timothy Sassone
#Window Layout and General Functionality

#import GUI libraries
from tkinter import *
from tkinter import ttk

#import custom libraries
from tag import Tag
import dicethrow2

root_tag = Tag(None, 'root')

root = Tk() #Create root window
#Prevent the user from moving menus.
root.option_add('*tearOff', FALSE)

menubar = Menu(root)
root['menu'] = menubar
menu_file = Menu(menubar)
menubar.add_cascade(menu=menu_file, label="File")

#Create notebook container
notebook = ttk.Notebook(root)
notebook.grid()


#OVERVIEW TAB DEFINITIONS
overview_tab = ttk.Frame(notebook); #create notebook "page"
notebook.add(overview_tab, text='Overview') #add "page" to notebook


#DETAILED TAB DEFINITIONS
detailed_tab = ttk.Frame(notebook);
#Create a treeview with a column for tag-data
tree = ttk.Treeview(detailed_tab, columns=('data'))
#Define column information
tree.column('data', width=250, anchor='center')
tree.heading('data', text='Data')
tree.grid() #Add treeview to page
notebook.add(detailed_tab, text='Detailed')





def clear_tag_data():
    root_tag = Tag(None, 'root')
def load_tag_data():
    fname = filedialog.askopenfilename(title="Choose a file",
                                       multiple=TRUE,
                                       filetypes=[("txt file",".txt"),
                                                  ("all files",".*")])
    if(fname!=None and fname!=""):
        root_tag.load_tags(fname)
def close_app():
    root.destroy()

menu_file.add_command(label="New", command=clear_tag_data)
menu_file.add_command(label="Load", command=load_tag_data)
menu_file.add_command(label="Close", command=close_app)






root.mainloop() #Start main loop
